<div class="popup_body">
    <div class="ui_table">
        <form method="post">
        <#assign areaText=''>
        <#if (entity.provinceName)??>
            <#assign provinceName=entity.provinceName>
            <#assign areaText=entity.provinceName>
        </#if>
        <#if (entity.cityName)??>
            <#assign cityName=entity.cityName>
            <#assign areaText=areaText + ' - ' + entity.cityName>
        </#if>
        <#if (entity.districtName)??>
            <#assign districtName=entity.districtName>
            <#assign areaText=areaText + ' - ' + entity.districtName>
        </#if>
            <input type="hidden" name="provinceId" value="${(entity.provinceId)!''}">
            <input type="hidden" name="cityId" value="${(entity.cityId)!''}">
            <input type="hidden" name="districtId" value="${(entity.districtId)!''}">
            <input type="hidden" name="id" value="${(entity.id)!''}">
            <input type="hidden" name="passportId" value="${(entity.passportId)!''}">
            <table cellpadding="0" cellspacing="0">
                <tr>
                    <td width="80" align="right">联系人：</td>
                    <td>
                        <input type="text" class="text easyui-validatebox" name="contact" required="required"
                               maxlength="10"
                               value="${(entity.contact)!''}"/>
                    </td>
                </tr>
                <tr>
                    <td width="80" align="right">电话：</td>
                    <td><input type="text" required="required" class="text easyui-validatebox" name="tel" maxlength="40"
                               value="${(entity.tel)!''}"/></td>
                </tr>
                <tr>
                    <td align="right">省份城市：</td>
                    <td>
                        <div class="select_city">
                            <input type="text" class="text easyui-validatebox"
                                   required="true" name="areaText" id="area_text_${pid}" value="${areaText}"/>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td align="right" valign="top" style="padding-top:10px;">详细地址：</td>
                    <td><input type="text" class="text easyui-validatebox" required="true" name="street" maxlength="20"
                               value="${(entity.street)!''}"/></td>
                </tr>
                <tr>
                    <td width="80" align="right">默认地址：</td>
                    <td>
                        <select name="defaultAddress" class="easyui-combobox"
                                style="width: 182px; height: 30px;" <#if entity.defaultAddress=1> disabled </#if>
                                editable="false">
                            <option value="0">否</option>
                            <option value="1" <#if 1==entity.defaultAddress>selected="selected"</#if>>是</option>
                        </select>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>
<div class="popup_btn">
    <button class="btn btn_red ok">确定</button>
    <button class="btn btn_border close">关闭</button>
</div>
<script>
    $(function () {
        var pid = '${pid}',
                win = $('#' + pid),
                form = win.find('form');

        $('#area_text_${pid}').click(function () {
            App.showArea({
                fn: function (v) {
                    var f = form[0];
                    f.areaText.value = v.areaText;
                    f.provinceId.value = v.provinceId;
                    f.cityId.value = v.cityId;
                    f.districtId.value = v.districtId;
                }
            });
        });

        win.find('button.ok').click(function () {
            form.form('submit', {
                url: '${contextPath}/security/basic/address_book/update.htm',
                success: function (text) {
                    var json = $.evalJSON(text);
                <@app.json_jump/>
                    if (json.success) {
                        $.messager.alert('提示信息', '操作成功', 'info');
                        win.window('close');
                    } else {
                        $.messager.alert('提示信息', json.message, 'info');
                    }
                }
            });
        });
        win.find('button.close').click(function () {
            win.window('close');
        });
    })
</script>